﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using WmsService.Derived;
using WmsService.In;
using WmsService.Out;
using WmsService.Reports;
using WmsService.Tacking;
using WmsService.Update;
using System.IO;
using WmsService.Util;
using WmsService.Entity;

namespace WmsService
{
    [ServiceContract]
    public interface IService
    {
        #region security
        /// <summary>
        /// 登陆系统，获取token
        /// </summary>
        /// <param name="userID">用户名</param>
        /// <param name="password">密码</param>
        /// <returns>token或者异常信息，格式："success:badstebdsfkopperqeirwqr" 或者："exception:用户名错误"</returns>
        [OperationContract]
        String Login(string userID, string password);

        [OperationContract]
        SystemUser GetSystemUser(string userID);

        [OperationContract]
        string ChangePassword(string userID, string oldPassword, string newPassword);

        [OperationContract]
        string SetPassword(string userID, string newPassword);
        #endregion

        #region Customer
        [OperationContract]
        List<Customer> GetCustomers();

        [OperationContract]
        List<Customer> GetCustomersByCondition(string condition);

        [OperationContract]
        Customer GetCustomer(string ownerNo);

        [OperationContract]
        void SaveCustomers(List<Customer> list);

        [OperationContract]
        void DeleteCustomer(string ownerNo);
        #endregion

        #region SystemUser
        [OperationContract]
        List<SystemUser> GetSystemUsers();

        [OperationContract]
        void SaveSystemUsers(List<SystemUser> list);
        #endregion

        #region GoodsCodeType
        [OperationContract]
        List<GoodsCodeType> GetGoodsCodeTypes();

        [OperationContract]
        List<GoodsCodeType> GetGoodsCodeTypesByCondition(string condition);

        [OperationContract]
        void SaveGoodsCodeTypes(List<GoodsCodeType> list);

        [OperationContract]
        void AddOrValidateGoodsCodeType(GoodsCodeType goodsCodeType);

        [OperationContract]
        void DeleteGoodsCodeType(GoodsCodeType goodsCodeType);

        [OperationContract]
        GoodsCodeType CancelGoodsCodeType(GoodsCodeType goodsCodeType);

        [OperationContract]
        GoodsCodeType UnCancelGoodsCodeType(GoodsCodeType goodsCodeType);
        #endregion

        #region InStoreBill
        [OperationContract]
        List<InStoreBill> GetInStoreBills();

        [OperationContract]
        List<InStoreBill> GetInStoreBillsByCondition(string condition);

        [OperationContract]
        void SaveInStoreBills(List<InStoreBill> list);

        [OperationContract]
        string ImportInStoreBillFromOutStoreBill(string outStorebillID);

        [OperationContract]
        InStoreBillWrap ImportInStoreBillFromOutStoreBill2(string outStorebillID);

        [OperationContract]
        List<OutStoreBill> GetAbnormalOutStoreBill(string condition);

        [OperationContract]
        List<String> GetAbnormalInStoreBillCodes();

        [OperationContract]
        List<OutInStoreBillType> GetOutInStoreBillTypes();
        #endregion

        #region InStoreBillDtl
        [OperationContract]
        List<InStoreBillDtl> GetInStoreBillDtls();

        [OperationContract]
        InStoreBillDtl GetInStoreBillDtl(string inStoreBillDtlID);

        [OperationContract]
        List<InStoreBillDtl> GetInStoreBillDtlsByCondition(string condition);

        [OperationContract]
        void SaveInStoreBillDtls(List<InStoreBillDtl> list);

        [OperationContract]
        void DeleteInStoreBillDtl(InStoreBillDtl dtl);
        #endregion

        #region OutStoreBill
        [OperationContract]
        List<OutStoreBill> GetOutStoreBills();

        [OperationContract]
        List<OutStoreBill> GetOutStoreBillsByCondition(string condition);

        [OperationContract]
        void SaveOutStoreBills(List<OutStoreBill> list);

        /// <summary>
        /// 查询出库单中所有的部门，distinct一下显示出来
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        List<String> GetOutStoreBillDepts();

        #endregion

        #region OutStoreBillDtl
        [OperationContract]
        List<OutStoreBillDtl> GetOutStoreBillDtls();

        [OperationContract]
        List<OutStoreBillDtl> GetOutStoreBillDtlsByCondition(string condition);

        [OperationContract]
        List<ExtendOutStoreBillDtl> GetExtendOutStoreBillDtlsByCondition(string condition);

        [OperationContract]
        decimal GetStoreGoodsQuantity(string newGoodsCode);

        [OperationContract]
        void SaveOutStoreBillDtls(List<OutStoreBillDtl> list);

        [OperationContract]
        void DeleteOutStoreBillDtl(OutStoreBillDtl dtl);
        #endregion

        #region StoreGoods 库存
        [OperationContract]
        List<StoreGoods> GetStoreGoodsList();

        [OperationContract]
        List<StoreGoods> GetStoreGoodsListByGoodsCodeType(string newGoodsCode);

        [OperationContract]
        List<StoreGoods> GetStoreGoodsListByCondition(string condition);

        [OperationContract]
        List<ExtendStoreGoods> GetExtendStoreGoodsListByCondition(string condition);

        [OperationContract]
        void SaveStoreGoodsList(List<StoreGoods> list);

        [OperationContract]
        void ImportStoreGoods(string newGoodsCode);
        #endregion

        #region StoreType
        [OperationContract]
        List<StoreType> GetStoreTypes();

        [OperationContract]
        void SaveStoreTypes(List<StoreType> list);
        #endregion

        #region Unit
        [OperationContract]
        List<Unit> GetUnits();

        [OperationContract]
        void SaveUnits(List<Unit> list);
        #endregion

        #region InStoreType
        [OperationContract]
        List<InStoreType> GetInStoreTypes();

        [OperationContract]
        void SaveInStoreTypes(List<InStoreType> list);
        #endregion

        #region OutStoreType
        [OperationContract]
        List<OutStoreType> GetOutStoreTypes();

        [OperationContract]
        List<OutStoreType> GetOutStoreTypesInConfig();

        [OperationContract]
        void SaveOutStoreTypes(List<OutStoreType> list);
        #endregion

        #region 业务操作

        [OperationContract]
        string GetInStoreBillID();

        [OperationContract]
        InStoreBillWrap GetInStoreBillWrap(string billID);

        [OperationContract]
        void SaveInStoreBillWrap(InStoreBillWrap inStoreBillWrap);

        [OperationContract]
        void AffirmInStoreBill(string billID);

        [OperationContract(Name = "AffirmInStoreBill2")]
        void AffirmInStoreBill(string billID, DateTime? outBillDate);

        [OperationContract]
        void AffirmInStoreBillInvoice(string billID, DateTime? inStoreBillInvoiceDate);

        [OperationContract]
        string GetOutStoreBillID();

        [OperationContract]
        OutStoreBillWrap GetOutStoreBillWrap(string billID);

        [OperationContract]
        void SaveOutStoreBillWrap(OutStoreBillWrap outStoreBillWrap);

        [OperationContract]
        void AffirmOutStoreBill(string billID);

        [OperationContract(Name = "AffirmOutStoreBill2")]
        void AffirmOutStoreBill(string billID,DateTime? outBillDate);

        #endregion

        #region 付款单相关

        [OperationContract]
        List<PayType> GetPayTypes();

        [OperationContract]
        void SavePayTypes(List<PayType> list);

        [OperationContract]
        List<PayApplyBill> GetPayApplyBills();

        [OperationContract]
        string GetPayApplyBillID();

        [OperationContract]
        List<PayApplyBill> GetPayApplyBillsByCondition(string condition);

        [OperationContract]
        void SavePayApplyBills(List<PayApplyBill> list);

        [OperationContract]
        List<PayApplyBillDtl> GetPayApplyBillDtls();

        [OperationContract]
        PayApplyBillDtl GetPayApplyBillDtl(string payApplyBillID, string invoiceNo);

        [OperationContract]
        List<PayApplyBillDtl> GetPayApplyBillDtlsByCondition(string condition);

        [OperationContract]
        void SavePayApplyBillDtls(List<PayApplyBillDtl> list);

        [OperationContract]
        PayApplyBillWrap GetPayApplyBillWrap(string billID);

        [OperationContract]
        void SavePayApplyBillWrap(PayApplyBillWrap payApplyBillWrap);

        [OperationContract]
        void AffirmPayApplyBill(string billID);

        [OperationContract]
        string NewPayApplyBillItem(PayApplyBillItem payApplyBillItem);

        [OperationContract]
        PayApplyBillItem GetPayApplyBillItem(string payApplyBillItemID);

        [OperationContract]
        List<PayApplyBillItem> GetPayApplyBillItemsByCondition(string condition);

        [OperationContract]
        void CancelPayApplyBillItem(string payApplyBillItemID);

        [OperationContract]
        List<String> GetPayApplyBillDepts();

        #endregion

        #region  Update

        [OperationContract]
        List<UpdateList> GetAllAssemblyVersions();

        [OperationContract]
        List<Byte[]> GetBytesByAssemblyName(List<String> tFileNames);

        [OperationContract]
        int PublishFile(string tFileName, Byte[] bytes);

        #endregion

        #region 发票相关

        [OperationContract]
        InvoiceBill GetInvoiceBill(string invoiceNo);

        [OperationContract]
        void SaveInvoiceBill(InvoiceBill invoiceBill);

        [OperationContract]
        void SaveInvoiceBillList(List<InvoiceBill> invoiceBills);

        [OperationContract]
        void DeleteInvoiceBill(string invoiceNo);

        [OperationContract]
        List<InvoiceBill> GetInvoiceBillsByCondition(string condition);

        [OperationContract]
        List<ExtendInvoiceBill> GetExtendInvoiceBillsByCondition(string condition);

        [OperationContract]
        List<ExtendInvoiceBillInStoreBill> GetExtendInvoiceBillInStoreBillsByCondition(string condition);

        [OperationContract]
        InvoiceBillInStoreBill GetInvoiceBillInStoreBill(string invoiceNo, string inStoreBillID);

        /// <summary>
        /// 将入库单从发票binding中去掉，也就是删除关系
        /// </summary>
        /// <param name="invoiceNo"></param>
        /// <param name="inStoreBillID"></param>
        [OperationContract]
        void CancelInStoreBillFromInvoiceBill(string invoiceNo, string inStoreBillID);

        [OperationContract]
        void SaveInvoiceBillInStoreBill(InvoiceBillInStoreBill invoiceBillInStoreBill);

        [OperationContract]
        void AddInvoiceBillInStoreBill(List<InvoiceBillInStoreBill> invoiceBillInStoreBills);

        [OperationContract]
        List<InvoiceBillInStoreBill> GetInvoiceBillInStoreBillsByCondition(string condition);

        #endregion

        #region Pay New
        [OperationContract]
        PayApplyBillInvoiceWrap GetPayApplyBillInvoiceWrap(string billID);

        [OperationContract]
        void SavePayApplyBillInvoiceWrap(PayApplyBillInvoiceWrap payApplyBillInvoiceWrap);

        [OperationContract]
        void AffirmPayApplyBillInvoice(string billID);

        [OperationContract]
        void AttachInvoiceBills2PayApplyBill(string payApplyBillID, List<ExtendInvoiceBill> invoiceBills);

        [OperationContract]
        void DeleteInvoiceBillFromPayApplyBill(string payApplyBillID, InvoiceBill invoiceBill);

        [OperationContract(Name = "DeleteInvoiceBillFromPayApplyBill2")]
        void DeleteInvoiceBillFromPayApplyBill(string payApplyBillID, string invoiceNo);
        #endregion

        #region View
        [OperationContract]
        List<VPreviewStoreGoods> GetVPreviewStoreGoodsListByCondition(string condition);
        #endregion

        #region 报表
        [OperationContract]
        DataSet GetDataSet(string dataSetName, List<ReportParameter> reportParameters);

        [OperationContract]
        List<Report> GetReports();

        [OperationContract]
        void SaveReports(List<Report> reports);

        [OperationContract]
        List<Report> GetReportsByCondition(string condition);

        [OperationContract]
        List<ReportDetail> GetReportDetails();

        [OperationContract]
        void SaveReportDetails(List<ReportDetail> reportDetails);

        [OperationContract]
        List<ReportDetail> GetReportDetailsByCondition(string condition);

        [OperationContract]
        ReportWrap GetReportWrap(string reportID);
        #endregion

        #region GetSpecificationTypeList
        [OperationContract]
        List<string> GetSpecificationTypeList();

        [OperationContract(Name = "GetSpecificationTypeListByNewGoodsCode")]
        List<string> GetSpecificationTypeList(string newGoodsCode);

        [OperationContract]
        List<Entity.SpecificationTypeItem> GetSpecificationTypeItemList();
        #endregion

        #region Extra
        /// <summary>
        /// 查询各种字段，distinct一下显示出来
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        List<DistinctEntity> GetDistinctEntities(string table, string field);
        #endregion

        #region 2010-10-28
        //================2010-10-28 added by henrik
        [OperationContract]
        void AddInvoiceBillInStoreBillDtl(List<InvoiceBillInStoreBillDtl> invoiceBillInStoreBillDtls);

        [OperationContract]
        List<InvoiceBillInStoreBillDtl> GetInvoiceBillInStoreBillDtls(string condition);

        [OperationContract]
        void CancelInStoreBillDtlFromInvoiceBill(string invoiceNo, string inStoreBillDtlID);

        /// <summary>
        /// 获得该程序能运行的最低版本，也就是不更新不给用
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        string GetLowestVersion();
        //==================================
        #endregion

        #region 2011-01-05
        /// <summary>
        /// 根据条件查询VInStoreBillDtlAndHead对象list
        /// </summary>
        /// <param name="condition">条件</param>
        /// <returns>VInStoreBillDtlAndHead的List</returns>
        [OperationContract]
        List<VInStoreBillDtlAndHead> GetVInStoreBillDtlAndHeadsByCondition(string condition);
        #endregion


        #region Tacking
        [OperationContract]
        string GetStockTackingId();

        [OperationContract]
        StockTackingWrap GetStockTackingWrap(string stockTackingNo);

        [OperationContract]
        void SaveStockTackingWrap(StockTackingWrap  stockTackingWrap);

        [OperationContract]
        void AffirmStockTacking(string stockTackingNo);

        [OperationContract]
        List<StockTacking> QueryStockTackingList(string condition);

        [OperationContract]
        List<ExtendStockTackingDtl> QueryStockTackingDtlList(string condition);

        [OperationContract]
        List<StockTacking> GetStockTackingList(string condition);

        [OperationContract]
        List<StockTackingDtl> GetStockTackingDtlList(string condition);

        [OperationContract]
        void DeleteStockTackingDtlList(List<StockTackingDtl> list);
        #endregion
    }
}
